package baidu;

/**
 * @Author LHL
 * @Datlist23-3-28-0028 17:18
 * @注释
 */

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static long num = 0;
    static int[] dp = new int[200005];

    static List<Integer>[] list = new List[200005];
    static String str = new String();

    public static void dfs(int a, int b) {
        dp[a] = 1;
        for (int listindex : list[a]) {
            if (listindex == b) {
                continue;
            }
            dfs(listindex, a);
            dp[a] += dp[listindex];
            if (str.charAt(a - 1) == str.charAt(listindex - 1)) {
                dp[a]--;
            }
        }
    }

    public static void dfsAgain(int a, int b) {
        for (int listindex : list[a]) {
            if (listindex == b) {
                continue;
            }
            dfsAgain(listindex, a);
            int x = dp[1] - dp[listindex];
            if (str.charAt(a - 1) == str.charAt(listindex - 1)) {
                x += 1;
            }
            num += Math.abs(x - dp[listindex]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        for (int i = 0; i <= a; i++) {
            list[i] = new ArrayList<>();
        }
        str = sc.nextLine();
        str = sc.nextLine();
        for (int i = 0; i < a - 1; i++) {
            int c = sc.nextInt();
            int d = sc.nextInt();

            list[c].add(d);
            list[d].add(c);
        }
        dfs(1, -1);

        dfsAgain(1, -1);

        System.out.println(num);
        return;
    }

}


